<template>
  <div>

    <zh-form ref="formInfo"  :rules="rules" :model="formInfo"  labelAlign="right" >

      <zh-card style="width:100%;float:left">

        <zh-row :span="18">
<!--          <zh-input prop="orgIds" type="tree" label="请选择巡查人员(可多选)" mode="multiple" placeholder="支持多选"
                    treeNodeFilterProp="title"
                    allowClear
                    multiple
                    tree-checkable
                    v-model="formInfo.patrolManList"
                    :treeData="patrolManData"
                    :span="18"
                    style="float: left" :labelCol="{span:6}" :wrapperCol="{span:18}"
          >
          </zh-input>-->
          <zh-input prop="patrolManList"   type="select"  
                    mode="multiple" :defaultFields='{label:"fullName",value:"userId",}' :options="patrolManData" label="请选择巡查人员(可多选)" v-model="formInfo.patrolManList"></zh-input>


        </zh-row>
        <div style="height: 50px">

        </div>
      </zh-card>
    </zh-form>
  </div>
</template>

<script>
import moment from 'moment'
import modal from "ant-design-vue/lib/modal";
import {getPatrolManData,patrolAllotTaskBatch
} from '@/services/system/whdngxlApi'
export default {
  components:{

  },
  props:{
    listQuery:{
      type:Function,
      default:null
    },
    d0706:{
      type:String,
      default:'1'
    },
  },
  data() {
    return {
      formInfo:{
        patrolManList:undefined,
      },
      rules: {
      },
      patrolManData: [],
    }
  },

  created() {},
  methods: {
    moment,
    initData(manageAreas){
      //获取巡查人员列表
      const params = {}
      params.manageAreas = manageAreas
      setTimeout(() => {
        this.$http.post(getPatrolManData, params).then((res) => {
          if(res.result){
            this.patrolManData = res.result
          }
        }).catch((error) => {
          console.log(JSON.stringify(error))
        }).finally(() =>{
        })
      }, 50)
    },
    allotTaskBatch(patrolManAllotVOList){
      // if(this.formInfo.patrolManList == null || this.formInfo.patrolManList.length === 0) {
      //   modal.warn({title: '温馨提示', content: '巡查人员不能为空'})
      //   return
      // }
      if(patrolManAllotVOList.length === 0){
        modal.warn({title: '温馨提示', content: '无可保存数据!'})
        return
      }
      this.$loading.show('正在处理数据,请等待...')
      const params = {}
      params.patrolManAllotVOList = patrolManAllotVOList
      params.patrolManList = this.formInfo.patrolManList
      params.d0706 = this.d0706
      setTimeout(() => {
        this.$http.post(patrolAllotTaskBatch, params).then((res) => {
          this.$loading.hide()
          this.$message.info('保存成功')
          this.$emit("handleCancel")
          if(this.listQuery){
            this.listQuery()
          }
        }).catch((error) => {
          this.$loading.hide()
          console.log(JSON.stringify(error))
        }).finally(() =>{
        })
      }, 50)
    },
  }
}
</script>

<style scoped>

</style>